package hmvictor.jpql.renderers;

import java.awt.Component;
import javax.persistence.Parameter;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Victor
 */
public class ParameterRenderer extends DefaultTableCellRenderer{

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        JLabel component = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 
        if(value != null) {
            Parameter parameter=(Parameter) value;
            if(parameter.getName() == null) {
                component.setText("Position "+parameter.getPosition());
            }else {
                component.setText("Name "+parameter.getName());
            }
        }
        return component; 
    }
    
}
